<!DOCTYPE html>
<html>
<head lang="en">
	<meta charset="UTF-8">
	<title>百朋后台管理系统</title>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/easyui/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/easyui/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/easyui/demo.css">
	<script type="text/javascript" src="__PUBLIC__/easyui/jquery.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/easyui/jquery.easyui.min.js"></script>
</head>
<style type="text/css">
	.input 
	{
		border: 1px solid #eaeaea;
		background-color: #6d654e;
		color: #fff;
		text-align: center;
		padding: 0px 10px -1px;
		border-radius: 4px;
	}
</style>
<body>
	<div class="list_table">
		<?php
			if ($type == '1') 
			{
				$title = '审核通过列表';
			}
			elseif ($type == '2') 
			{
				$title = '待审核商户列表';
			}
			elseif ($type == '3') 
			{
				$title = '审核未过商户列表';
			}
		?>
		<table id="list_table" title="<?php echo $title; ?>" style="width:100%;height:372px;" 
			data-options="
				rownumbers:true,
				singleSelect:true,
				autoRowHeight:false,
				pagination:true,
				pageSize:10,toolbar:'#tb'
			"
		>
			<thead>
				<tr>
					<th field="merchant_name" width="25%" align="center">商户全称</th>
					<th field="merchant_abbreviation" width="15%" align="center">商户简称</th>
					<th field="corporates" width="10%" align="center">法人</th>
					<th field="corporate_phone" width="10%" align="center">法人电话</th>
					<th field="interest_rate" width="7%" align="center">商户利率</th>
					<th field="author" width="7%" align="center">报告人</th>
					<th field="edttime" width="10%" align="center">报告时间</th>
					<th field="action" width="15%" align="center" formatter="formatAction">操作</th>
				</tr>
			</thead>
		</table>
	</div>

	<div id="tb" style="padding:5px;height:auto">
		<form action="../../facilitator/facilitator/pending_list" method="get" id="searchTable">
			<input type="hidden" name="type" value="<?php echo $type; ?>">
			<div>
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;商户名称: <input class="easyui-textbox" id="select_name" name="select_name" value="{$_GET['select_name']}" data-options="prompt:'关键字搜索...'" style="width:120px">&nbsp;&nbsp;&nbsp;&nbsp;
				报告人: 
				<select class="easyui-combobox selector" id="select_user" name="select_user" panelHeight="auto" style="width:120px" data-options="editable:false">
					<option value="">请选择</option>
					<?php
						foreach ($array_user as $key => $value) 
						{
							echo '<option value="'.$value['user_name'].'">'.$value['user_name'].'</option>';
						}
					?>
				</select>&nbsp;&nbsp;&nbsp;&nbsp;
				<script type="text/javascript">$("#select_user").find("option[value='{$_GET['select_user']}']").attr("selected",true);</script>
				报告时间: 
				<input class="easyui-datebox" id="select_time" data-options="formatter:myformatter,parser:myparser,editable:false" name="select_time" value="{$_GET['select_time']}" style="width:120px">&nbsp;&nbsp;&nbsp;&nbsp;
				<a href="javascript:;" onclick="submitSearch();" class="easyui-linkbutton" iconCls="icon-search">查询</a>&nbsp;&nbsp;
				<a href="javascript:;" onclick="resetSearch();" class="easyui-linkbutton" iconCls="icon-clear">重置</a>&nbsp;&nbsp;
				
			</div>
		</form>
	</div>

	<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
	<script type="text/javascript">
		$(function() 
		{
			var json = '{$json_list}';
			var array = JSON.parse(json);
			$('#list_table').datagrid({loadFilter:pagerFilter}).datagrid('loadData', array);
		});

		function formatAction(value,row,index) 
		{
			if (row.mark == '2') 
			{
				var a = '<input type="button" value="详情" class="input" onclick="checkinfo_see('+row.id+');">';
				var b = '<input type="button" value="通过" class="input" onclick="facilitator_check(1,'+row.id+');">';
				var c = '<input type="button" value="拒绝" class="input" onclick="facilitator_check(2,'+row.id+');">';
			}
			else if (row.mark == '1') 
			{
				var a = '<input type="button" value="详情" class="input" onclick="checkinfo_see('+row.id+');">';
				var b = '<input type="button" value="签约资料" class="input" onclick="signinfo_edit('+row.id+','+row.facilitator_info_id+');">';
				var c = '<input type="button" value="签约" class="input" onclick="signed(1,'+row.facilitator_info_id+');">';
			}
			else
			{
				var a = '<input type="button" value="详情" class="input" onclick="checkinfo_edit('+row.visitlog_id+');">';
				var b = '<input type="button" value="重新审核" class="input" onclick="facilitator_check(3,'+row.id+');">';
				var c = '';
			}
			return a+b+c;
		}

		function checkinfo_edit(visitlog_id) 
		{
			window.parent.addTab('审核资料编辑','../../facilitator/visitlog/visitlog_checkinfo?visitlog_id='+visitlog_id);
		}

		function checkinfo_see(id) 
		{
			window.parent.addTab('审核资料详情','../../facilitator/facilitator/checkinfo_see?id='+id);
		}

		//	通过动作
		function facilitator_check(type,id) 
		{
			if (type == '1') 
			{
				var msg = "您正在通过该商户审核，请输入审核意见：";
				var cont = "通过";
			}
			else if (type == '2') 
			{
				var msg = "您正在拒绝该商户审核，请输入审核意见：";
				var cont = "拒绝";
			}
			else if (type == '3') 
			{
				var msg = "您确定重新审核该商户吗？\n\n重新审核会把商户转入待审核列表页，请确认！";
			}

			if (type == '3') 
			{
				if (confirm(msg)==true) 
				{
					var url = "../../facilitator/facilitator/facilitator_check";
					$.ajax({
						type: "POST",
						async: true,
						data: {"type":type,"checkData":id},
						url: url,
						success: function(d) 
						{
							if (d == 1) 
							{
								window.location.reload();
							}
							else
							{
								alert('操作失败，请尝试重新操作或联系管理员！');
								window.history.back(); 
							}
						},
						error: function(e) 
						{
							alert(e);
						}
					});
				}
				else
				{
					return false;
				}
			}
			else
			{
				var content = prompt(msg,cont);
				if (content) 
				{
					var url = "../../facilitator/facilitator/facilitator_check";
					$.ajax({
						type: "POST",
						async: true,
						data: {"type":type,"checkData":id,"content":content},
						url: url,
						success: function(d) 
						{
							if (d == 1) 
							{
								window.location.reload();
							}
							else
							{
								alert('操作失败，请尝试重新操作或联系管理员！');
								window.history.back(); 
							}
						},
						error: function(e) 
						{
							alert(e);
						}
					});
				}
			}

			// var name = prompt("您正在通过该商户审核，请输入审核意见：", "");
			// if (type == '1') 
			// {
			// 	var msg = "您确定通过该商户审核吗？\n\n请确认！";
			// }
			// else if (type == '2') 
			// {
			// 	var msg = "您确定拒绝该商户审核吗？\n\n请确认！";
			// }
			// else if (type == '3') 
			// {
			// 	var msg = "您确定重新审核该商户吗？\n\n重新审核会把商户转入待审核列表页，请确认！";
			// }
			
			// if (confirm(msg)==true) 
			// {
			// 	var url = "../../facilitator/facilitator/facilitator_check";
			// 	$.ajax({
			// 		type: "POST",
			// 		async: true,
			// 		data: {"type":type,"checkData":id},
			// 		url: url,
			// 		success: function(d) 
			// 		{
			// 			if (d == 1) 
			// 			{
			// 				window.location.reload();
			// 			}
			// 			else
			// 			{
			// 				alert('操作失败，请尝试重新操作或联系管理员！');
			// 				window.history.back(); 
			// 			}
			// 		},
			// 		error: function(e) 
			// 		{
			// 			alert(e);
			// 		}
			// 	});
			// }
			// else
			// {
			// 	return false;
			// }
		}

		//	签约动作
		function signed(type,id) 
		{
			var msg = "您确定已经签约该商户吗？\n\n请确认！";
			if (confirm(msg)==true) 
			{
				var url = "../../facilitator/facilitator/signed";
				$.ajax({
					type: "POST",
					async: true,
					data: {"type":type,"signedData":id},
					url: url,
					success: function(d) 
					{
						if (d == 1) 
						{
							window.location.reload();
						}
						else
						{
							alert('操作失败，请尝试重新操作或联系管理员！');
							window.history.back(); 
						}
					},
					error: function(e) 
					{
						alert(e);
					}
				});
			}
			else
			{
				return false;
			}
		}

		function signinfo_edit(id,facilitator_info_id) 
		{
			window.parent.addTab('签约资料编辑','../../facilitator/facilitator/signinfo_edit?id='+id+'&facilitator_info_id='+facilitator_info_id);
		}

		function submitSearch() 
		{
			$("#searchTable").submit();
		}

		function resetSearch() 
		{
			$("#select_name").textbox("setValue","");
			$("#select_user").combobox("setValue","");
			$("#select_time").textbox("setValue","");
		}
	</script>
</body>
</html>